/**
 * Created by Gordeev on 16.08.2014.
 */
var createModel = function (mongoose) {
    var Schema = mongoose.Schema;

    var schema = new Schema({
        requestUrl: {
            type: String,
            required: false
        },
        requestMethod: {
            type: String,
            required: false
        },
        responseTime: {
            type: Number,
            required: true,
            default: 0
        },
        responseStatus: {
            type: String,
            required: false
        },
        referrer: {
            type: String,
            required: false
        },
        remoteAddress: {
            type: String,
            required: false
        },
        httpVersion: {
            type: String,
            required: false
        },
        userAgent: {
            type: String,
            required: false
        },
        userName: {
            type: String,
            required: false
        },
        date: {
            type: Date,
            required: true,
            default: new Date(),
            index: true
        },
        error: {
            type: String,
            required: false
        }
    }, {
        capped: 262144
    });

    return mongoose.model('Log', schema);
};

exports.createLogRecordModel = createModel;